/**
 * KnowledgeOutlineController.java
 * Version 1.0.0
 * Created on 2018年7月16日
 *
 */
package com.yincheng.oes.business.base.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yincheng.oes.business.base.entity.KnowledgeOutline;
import com.yincheng.oes.business.base.entity.KnowledgeRoot;
import com.yincheng.oes.business.base.entity.Question;
import com.yincheng.oes.business.base.service.KnowledgeOutlineService;

/**
 * @author yangsy
 * @version 1.0.0
 * @since
 * 创建时间：2018年7月16日
 * 功能描述：
 * 邮箱地址：446948434@qq.com
 */
@Controller
@RequestMapping("/outline")
public class KnowledgeOutlineController {

    @Autowired
    private KnowledgeOutlineService knowledgeOutlineService;

    /**
     * 根据父节点id获取子节点列表
     * 异步查询接口
     *
     * @param parentId
     * @return
     */
    @RequestMapping(value = "/getOutLineList.json", method = RequestMethod.GET)
    @ResponseBody
    public List<KnowledgeOutline> getOutLineList(Integer parentId) {
        List<KnowledgeOutline> list = knowledgeOutlineService.getKnowledgeOutlinesByParentId(parentId);
        return list;
    }

    @RequestMapping(value = "/getOutLineListExt.json", method = RequestMethod.GET)
    @ResponseBody
    public List<KnowledgeOutline> getOutLineListExt(Integer parentId, Integer yearNum, String outlineType) {
        if (parentId == null) {
            List<KnowledgeOutline> list = knowledgeOutlineService.getKnowledgeOutlinesByYearAndType(yearNum,
                    outlineType);
            return list;
        } else {
            List<KnowledgeOutline> list = knowledgeOutlineService.getKnowledgeOutlinesByParentId(parentId);
            return list;
        }
    }

    /**
     * 根据大纲id获取关联的题目列表
     *
     * @param outlineId
     * @return
     */
    @RequestMapping(value = "/getQuestionList.json", method = RequestMethod.GET)
    @ResponseBody
    public List<Question> getQuestionList(Integer outlineId) {
        List<Question> list = knowledgeOutlineService.getQuestionsByOutlineId(outlineId);
        return list;
    }

    @RequestMapping(value = "/getRootOutlines.json", method = RequestMethod.GET)
    @ResponseBody
    public List<KnowledgeRoot> getRootOutlines() {
        List<KnowledgeRoot> list = knowledgeOutlineService.getRootOutlines();
        return list;
    }
}
